home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / src / WBBump_src.lha / WBBump_src / errors.e < prev    next >
Encoding:
Text File  |  1999-06-30  |  3.7 KB  |  151 lines

  1. /* ******** */
  2. /* errors.e */
  3. /* ******** */
  4.  
  5.  
  6. /*
  7.     WBBump - Bumpmapping on the Workbench!
  8.  
  9.     Copyright (C) 1999  Thomas Jensen - dm98411@edb.tietgen.dk
  10.  
  11.     This program is free software; you can redistribute it and/or modify
  12.     it under the terms of the GNU General Public License as published by
  13.     the Free Software Foundation; either version 2 of the License, or
  14.     (at your option) any later version.
  15.  
  16.     This program is distributed in the hope that it will be useful,
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.     GNU General Public License for more details.
  20.  
  21.     You should have received a copy of the GNU General Public License
  22.     along with this program; if not, write to the Free Software Foundation,
  23.     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  24. */
  25.  
  26.  
  27.  
  28. OPT MODULE
  29.  
  30.  
  31.  
  32. MODULE    'intuition/intuition'
  33.  
  34.  
  35. DEF    errorstring
  36.  
  37.  
  38. EXPORT ENUM    ERR_NONE,
  39.             ERR_LOCKSCR,
  40.             ERR_OPENWINDOW,
  41.             ERR_INTERNAL,
  42.             ERR_LOCKCIMG,
  43.             ERR_CREATEMSGPORT,
  44.             ERR_CXBROKER,
  45.             ERR_BADSCREEN,
  46.             ERR_CXLIB,
  47.             ERR_ICONLIB,
  48.             ERR_CGXLIB,
  49.             ERR_UTILLIB,
  50.             ERR_DTLIB,
  51.             ERR_WBLIB,
  52.             ERR_DT,
  53.             ERR_CREATEPORT,
  54.             ERR_THREAD,
  55.             ERR_ALLOCSIGNAL,
  56.             ERR_PLUGIN,
  57.             ERR_LOADPLUGIN,
  58.             ERR_PLUGININIT
  59.  
  60.  
  61. OBJECT errtab
  62.     err
  63.     desc
  64. ENDOBJECT
  65.  
  66.  
  67. EXPORT PROC show_error(id, txt, report=TRUE)
  68.     DEF    str[4096]:STRING,
  69.         table=NIL:PTR TO errtab,
  70.         i
  71.  
  72.     table := [
  73.         ERR_LOCKSCR, 'Unable to lock specified screen',
  74.         ERR_OPENWINDOW, 'Unable to open window,\nmaybe you''re out of memory',
  75.         ERR_INTERNAL, 'Interal error (please contact author)',
  76.         ERR_LOCKCIMG, 'Unable to lock an internal image buffer\nThis should not happen under normal circumstances,\nplease contact the author',
  77.         ERR_CREATEMSGPORT, 'Unable to create messageport\nMight be a memory problem',
  78.         ERR_CXBROKER, 'Unable to create Commodity',
  79.         ERR_BADSCREEN, 'The chosen screen is not appropriate\n to run WBBump on.\nWBBump needs a CyberGraphics screen',
  80.         ERR_CXLIB, 'This program needs commodities.library V37+',
  81.         ERR_ICONLIB, 'This program needs icon.library V39+',
  82.         ERR_CGXLIB, 'This program needs cybergraphics.library V39+',
  83.         ERR_UTILLIB, 'This program needs utilities.library V39+',
  84.         ERR_DTLIB, 'This program needs datatypes.library V39+',
  85.         ERR_WBLIB, 'Unable to open workbench.library V39+',
  86.         ERR_DT, 'Datatypes error',
  87.         ERR_CREATEPORT, 'Unable to create messageport\nMemory error?',
  88.         ERR_THREAD, 'Thread error',
  89.         ERR_ALLOCSIGNAL, 'Unable to alloc signal\n(internal error)',
  90.         ERR_PLUGIN, 'Plugin error',
  91.         ERR_LOADPLUGIN, 'Unable to load plugin',
  92.         ERR_PLUGININIT, 'Error in plugin initialization',
  93.         0]:errtab
  94.  
  95.  
  96.     i := 0
  97.     WHILE (table[i].err <> 0) AND (table[i].err <> id)
  98.         i++
  99.     ENDWHILE
  100.  
  101.  
  102.     IF (table[i].err = 0)
  103.         StringF(str,    'An error has occured\n'+
  104.                         'ErrorID: \z\h[8]\n'+
  105.                         '\s',
  106.                         id, txt)
  107.     ELSE
  108.         StringF(str,    'An error has occured\n'+
  109.                         '\s\n'+
  110.                         '\s\n'+
  111.                         'ErrorID: \z\h[8]',
  112.                         table[i].desc, txt, id)
  113.     ENDIF
  114.  
  115.  
  116.     showWarning('WBBump error', 'Quit', str)
  117.  
  118. ENDPROC
  119.  
  120.  
  121. EXPORT PROC showWarning(wintitle, buttons, fmtstr, argstream=NIL:PTR TO LONG)
  122.     DEF    contents[8192]:ARRAY OF CHAR
  123.  
  124.     IF argstream
  125.         RawDoFmt(fmtstr, argstream, {putchproc}, contents)
  126.         RETURN EasyRequestArgs(0, [20, 0, wintitle, contents, buttons], 0, [NIL])
  127.     ELSE
  128.         RETURN EasyRequestArgs(0, [20, 0, wintitle, fmtstr, buttons], 0, [NIL])
  129.     ENDIF
  130.  
  131. ENDPROC NIL
  132.  
  133.  
  134. /* enhanced Throw() */
  135. EXPORT PROC eThrow(excid, excinfo, argstream=NIL:PTR TO LONG)
  136.     IF errorstring = NIL THEN errorstring := NewR(4096)
  137.  
  138.     IF argstream
  139.         RawDoFmt(excinfo, argstream, {putchproc}, errorstring)
  140.         Throw(excid, errorstring)
  141.     ELSE
  142.         Throw(excid, excinfo)
  143.     ENDIF
  144. ENDPROC
  145.  
  146.  
  147. putchproc:
  148.     MOVE.B    D0,(A3)+
  149.     RTS
  150.  
  151.